package com.hua.springCloud.service;




import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;

import java.util.UUID;

//绑定交换机与频道（个人理解）// 可以理解为是一个消息的发送管道的定义
@EnableBinding(Source.class)
public class MessageSendImpl implements MessageSend{

    //消息频道 其实就是定义队列 // 消息的发送管道
    @Autowired
    private MessageChannel output;

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial+"").build());
        System.out.println("信息为："+serial);
        return null;
    }
}
